<script type="text/javascript">
	$(document).ready(function(){
		$("input[name='data[Banner][kind]']").each(function(){
			$(this).bind("click", function(){
				var rbv = $("input[name='data[Banner][kind]']:checked").val();
				if(rbv=="I"||rbv=="F") {
					$("#Kind1").show();
					$("#Kind2").hide();
				} else {
					$("#Kind2").show();
					$("#Kind1").hide();
				}
			});
		});
		$("input[name='data[Banner][kind]']:checked").click();
	});
</script>
<h1><?php echo $this->pageTitle = __('Add/Edit Ad', true); ?></h1>
<div class="form">
	<?php 
		echo $form->create('Banner', array('type'=>'file'));
	?>
	<fieldset>
		<?php
			echo $form->input('id');
			if (!$html->value('campaign_id')) {
				echo $form->input('campaign_id', array('type'=>'select', 'label'=>__('Campaign', true).':', 'options'=>$campaigns));
			} else {
				echo $form->input('campaign_id', array('type'=>'hidden'));
			}
			echo $form->input('referer', array('type'=>'hidden'));
			echo $form->input('title', array('label'=>__('Title (alt)', true).':', 'error' => __('Title is required.', true)));
			echo $form->input('link', array('label'=>__('Link', true).':', 'error' => __('Link must be in a proper form or empty.', true)));
			
			echo $form->input('width', array('label'=>__('Width', true).':', 'error' => __('Width has to be numeric.', true)));
			echo $form->input('height', array('label'=>__('Height', true).':', 'error' => __('Height has to be numeric.', true)));
			echo $form->input('kind', array(
				'type'    => 'radio',
				'options' => array('I'=>__('Image', true), 'F'=>__('Flash', true), 'P'=>__('Plain Text', true), 'H'=>__('Html', true)),
				'legend'  => __('Type', true).':'));
		?>
	</fieldset>
	<fieldset id="Kind1">
		<?php
			echo $form->input('filename', array('type'=>'file', 'label'=>__('File', true).':'));
			echo '<div class="input">'.$html->value('filename').'</div>';
		?>
	</fieldset>
	<fieldset id="Kind2">
		<?php
			echo $form->input('body', array('label'=>__('Text/HTML', true).':'));
		?>
	</fieldset>
	<?php echo $form->end('OK');?>
</div>